Skip to content

fix(generate-types): preserve infer inside tuple types in extends clause#41

Merged
alexander-akait merged 1 commit into
mainfrom
claude/webpack-type-generation-72cmrd
Jun 16, 2026
Merged

fix(generate-types): preserve infer inside tuple types in extends clause#41
alexander-akait merged 1 commit into
mainfrom
claude/webpack-type-generation-72cmrd

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Summary

generate-types dropped the infer keyword when a conditional type's extends clause used infer inside a tuple element/rest slot (e.g. T extends readonly [infer H, ...any[]]), collapsing infer H/...infer R to free references H/R and emitting invalid types.d.ts (TS2304: Cannot find name 'H'/'R'). getExtendsString handled infer in type-parameter and array positions but not tuples. This renders tuples in extends position element-wise so infer survives, honoring rest/variadic/optional element flags and the readonly modifier.

Closes webpack/webpack#21191

What kind of change does this PR introduce?

fix

Did you add tests for your changes?

No — tooling has no test harness for generate-types; verified by running generate-types against a fixture with the issue's Head/Tail typedefs (output now emits infer H/...infer R and passes tsc --strict, whereas the old output failed with TS2304) and confirmed by regenerating webpack's types.d.ts in webpack/webpack#21201.

Does this PR introduce a breaking change?

No.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

n/a

Use of AI

AI (Claude) was used to apply and verify the fix (fixture-based round-trip plus tsc); reviewed before committing.


Generated by Claude Code

Render tuple types in conditional `extends` position element-wise so
`infer` in an element or rest slot survives instead of collapsing to a
free type reference, which produced invalid types.d.ts (TS2304).

Fixes webpack/webpack#21191
@alexander-akait alexander-akait merged commit d3ca82b into main Jun 16, 2026
7 checks passed
@alexander-akait alexander-akait deleted the claude/webpack-type-generation-72cmrd branch June 16, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Type generation (tooling/generate-types) drops infer inside tuple types, producing invalid types.d.ts

1 participant